﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
	xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:local="clr-namespace:GreetingCreator;assembly=GreetingCreatorControl"
    xmlns:itemPicker="clr-namespace:ItemPicker;assembly=ItemPickerControl"    
    xmlns:transform="clr-namespace:TransformInteraction;assembly=TransformInteraction" 
    xmlns:waitCursor="clr-namespace:WaitCursor;assembly=WaitCursor"
    >

    <Style TargetType="local:CaptchaControl">
        <Setter Property="InfoText" Value="Type the 4 characters above:" />
        <Setter Property="ReloadText" Value="Reload captcha" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CaptchaControl">
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="Updating">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <ContentControl Grid.Row="0" x:Name="PART_CaptchaContainer" Height="100"/>

                        <Grid Grid.Row="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <StackPanel Grid.Column="0">
                                <TextBlock Text="{TemplateBinding InfoText}" FontSize="10"/>
                                <TextBox x:Name="PART_CaptchaInput" Background="#66FFFFFF" HorizontalAlignment="Left" Width="120" />
                            </StackPanel>                                 
                            <Button x:Name="PART_ReloadButton" Grid.Column="1" Width="40" Height="40" Template="{StaticResource simpleButtonTemplate}">
                                <ToolTipService.ToolTip>
                                    <TextBlock Text="{TemplateBinding ReloadText}" />
                                </ToolTipService.ToolTip>
                                <Button.Content>
                                    <Canvas x:Name="reloadIcon" Width="119.703" Height="126.332" HorizontalAlignment="Center" VerticalAlignment="Center" Clip="F1 M 0,0L 119.703,0L 119.703,126.332L 0,126.332L 0,0" RenderTransformOrigin="0.5,0.5">
                                        <Canvas.RenderTransform>
                                            <ScaleTransform ScaleX="0.3" ScaleY="0.3" />
                                        </Canvas.RenderTransform>
                                        <Canvas x:Name="Layer_1" Width="119.703" Height="126.332" Canvas.Left="0" Canvas.Top="0">
                                            <Path x:Name="Path" Width="41.7791" Height="81.8995" Canvas.Left="8.9411" Canvas.Top="14.3824" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 39.9109,45.2286L 50.2202,50.6726L 44.7407,14.8824L 12.1142,30.5817L 22.758,36.1353L 22.5645,36.5172L 19.2176,42.9L 15.2181,50.6768L 11.4408,58.2314L 9.4411,65.5638L 9.88556,72.8962L 12.3297,81.1174L 23.7724,95.782L 36.1043,82.8949L 32.1049,78.8955L 29.2164,73.3406L 27.4388,68.2302L 28.1054,64.2307L 31.4383,58.2314L 34.9935,51.5656L 39.0532,44.8011L 39.9294,45.2383">
                                                <Path.Fill>
                                                    <LinearGradientBrush StartPoint="0.370509,0.468544" EndPoint="0.906082,0.468544">
                                                        <LinearGradientBrush.RelativeTransform>
                                                            <TransformGroup>
                                                                <SkewTransform CenterX="0.370509" CenterY="0.468544" AngleX="28.3289" AngleY="0"/>
                                                                <RotateTransform CenterX="0.370509" CenterY="0.468544" Angle="-49.3743"/>
                                                            </TransformGroup>
                                                        </LinearGradientBrush.RelativeTransform>
                                                        <LinearGradientBrush.GradientStops>
                                                            <GradientStop Color="#FFE20000" Offset="0.00847458"/>
                                                            <GradientStop Color="#FFE55D5D" Offset="0.368644"/>
                                                            <GradientStop Color="#FFE8BBBB" Offset="1"/>
                                                        </LinearGradientBrush.GradientStops>
                                                    </LinearGradientBrush>
                                                </Path.Fill>
                                            </Path>
                                            <Path x:Name="Path_0" Width="60.7036" Height="56.9088" Canvas.Left="51.269" Canvas.Top="8.62604" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 85.5222,48.5792L 76.4398,55.8885L 111.473,65.0348L 109.982,28.8583L 100.666,36.4315L 100.392,36.1025L 95.8576,30.501L 90.3013,23.7481L 84.861,17.2872L 78.9205,12.5464L 72.0118,10.0499L 64.2119,9.12604L 51.769,11.1259L 54.6575,30.0123L 59.9901,27.5682L 65.3228,27.1238L 69.3429,28.0157L 72.7511,30.212L 76.9393,35.6488L 81.6516,41.5537L 86.2545,47.9608L 85.506,48.5923">
                                                <Path.Fill>
                                                    <LinearGradientBrush StartPoint="0.675474,0.78094" EndPoint="1.00201,0.78094">
                                                        <LinearGradientBrush.RelativeTransform>
                                                            <TransformGroup>
                                                                <SkewTransform CenterX="0.675474" CenterY="0.78094" AngleX="-1.7713" AngleY="0"/>
                                                                <RotateTransform CenterX="0.675474" CenterY="0.78094" Angle="-76.8237"/>
                                                            </TransformGroup>
                                                        </LinearGradientBrush.RelativeTransform>
                                                        <LinearGradientBrush.GradientStops>
                                                            <GradientStop Color="#FFE20000" Offset="0.00847458"/>
                                                            <GradientStop Color="#FFE55D5D" Offset="0.368644"/>
                                                            <GradientStop Color="#FFE8BBBB" Offset="1"/>
                                                        </LinearGradientBrush.GradientStops>
                                                    </LinearGradientBrush>
                                                </Path.Fill>
                                            </Path>
                                            <Path x:Name="Path_1" Width="80.2843" Height="51.9897" Canvas.Left="29.4225" Canvas.Top="66.3421" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 56.4985,87.0308L 54.2067,75.6L 29.9225,102.456L 62.7027,117.832L 60.2845,106.072L 60.7028,105.981L 67.765,104.544L 76.3202,102.732L 84.5628,100.888L 91.5103,97.8064L 98.4303,92.227L 103.652,85.5613L 109.207,72.8962L 89.8824,66.8421L 87.5289,71.8153L 85.0473,77.5636L 82.2084,82.1698L 78.6868,84.1794L 71.9307,85.3854L 64.5174,86.8401L 56.709,87.9659L 56.4944,87.0104">
                                                <Path.Fill>
                                                    <LinearGradientBrush StartPoint="0.582419,0.595891" EndPoint="1.00449,0.595891">
                                                        <LinearGradientBrush.RelativeTransform>
                                                            <TransformGroup>
                                                                <SkewTransform CenterX="0.582419" CenterY="0.595891" AngleX="10.3177" AngleY="0"/>
                                                                <RotateTransform CenterX="0.582419" CenterY="0.595891" Angle="262.369"/>
                                                            </TransformGroup>
                                                        </LinearGradientBrush.RelativeTransform>
                                                        <LinearGradientBrush.GradientStops>
                                                            <GradientStop Color="#FFE20000" Offset="0.00847458"/>
                                                            <GradientStop Color="#FFE55D5D" Offset="0.368644"/>
                                                            <GradientStop Color="#FFE8BBBB" Offset="1"/>
                                                        </LinearGradientBrush.GradientStops>
                                                    </LinearGradientBrush>
                                                </Path.Fill>
                                            </Path>
                                        </Canvas>
                                    </Canvas>
                                </Button.Content>
                            </Button>                                
                        </Grid>

                        <waitCursor:WaitCursorControl Grid.Row="0" Grid.RowSpan="2" x:Name="disableControlsArea" Background="#99FFFFFF" Visibility="Collapsed" Text="Updating..." />

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="local:GreetingCreatorControl">
        <Setter Property="SendText" Value="Send" />
        <Setter Property="EmailSubject" Value="You have recieved a greeting from {0}!" />
        <Setter Property="EmailMessageTemplate" Value="You find your greeting if you go to the following address: http://localhost/ViewGreeting.aspx?greetingid={0}" />
        <Setter Property="SucceededMessageTemplate" Value="Your message has been saved and sent and you can find it here: http://localhost/ViewGreeting.aspx?greetingid={0}. You can also embedd your message in your own site with this code: &lt;IFRAME src=http://foo.bar/greeting/Embedded.aspx?greetingid={0} width=550 height=450 /&gt;" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:GreetingCreatorControl">
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="Succeeded">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="messageSaved" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="CaptchaFailed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="messageCaptchaFailed" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="SendEmailFailed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="messageSavedButNotSent" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="ReceivingGreetingMode">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(WaitCursorControl.Text)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Receiving..." />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="SendingGreetingMode">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(WaitCursorControl.Text)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Sending..." />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="disableControlsArea" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidEmail">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="PART_SenderEmail" Storyboard.TargetProperty="(UIElement.Background).(SolidColorBrush.Color)" RepeatBehavior="Forever">
                                            <LinearColorKeyFrame Value="#88FF0000" KeyTime="00:00:01" />
                                            <LinearColorKeyFrame Value="#66FFFFFF" KeyTime="00:00:02" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidSendTo">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="PART_SendTo" Storyboard.TargetProperty="(UIElement.Background).(SolidColorBrush.Color)" RepeatBehavior="Forever">
                                            <LinearColorKeyFrame Value="#88FF0000" KeyTime="00:00:01" />
                                            <LinearColorKeyFrame Value="#66FFFFFF" KeyTime="00:00:02" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="PresentationStates">
                                <vsm:VisualState x:Name="ReadMode">
                                    <Storyboard/>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="EditMode">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="sendInfoContainer" Storyboard.TargetProperty="(Border.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="messageInput" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="00:00:00" Value="#66000000"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Border Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="4" Background="#FFFFF8F8">
                            <Grid>
                                                                
                                <TextBox x:Name="messageInput" TextWrapping="Wrap" FontSize="16" VerticalAlignment="Bottom" Height="150" Background="Transparent" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" IsReadOnly="{TemplateBinding IsReadOnly}" Text="{Binding Message, Mode=TwoWay}" Padding="30,10,30,10" BorderThickness="1" BorderBrush="Transparent"/>

                                <local:GraphicElementListBox x:Name="graphicElements" ItemsSource="{Binding GraphicElements}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                    
                                    <local:GraphicElementListBox.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <Canvas HorizontalAlignment="Center" VerticalAlignment="Center" />
                                        </ItemsPanelTemplate>
                                    </local:GraphicElementListBox.ItemsPanel>

                                    <local:GraphicElementListBox.ItemContainerStyle>
                                        <Style TargetType="ListBoxItem">
                                            <Setter Property="Background" Value="Transparent" />
                                            <Setter Property="HorizontalAlignment" Value="Center" />
                                            <Setter Property="VerticalAlignment" Value="Center" />
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="ListBoxItem">
                                                        <transform:TransformControl Angle="{Binding Angle, Mode=TwoWay}" PositionX="{Binding PositionX, Mode=TwoWay}" PositionY="{Binding PositionY, Mode=TwoWay}">
                                                            <ContentPresenter />
                                                        </transform:TransformControl>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </local:GraphicElementListBox.ItemContainerStyle>
                                </local:GraphicElementListBox>

                            </Grid>
                        </Border>

                        <Border x:Name="sendInfoContainer" Grid.Row="1" Visibility="Collapsed" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="4,0,4,4">
                            <Grid>                                
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>

                                <StackPanel Grid.Row="0" Grid.Column="0" Margin="5">
                                    <TextBlock VerticalAlignment="Bottom" Text="Your Name" TextWrapping="Wrap" FontSize="10"/>
                                    <TextBox  x:Name="PART_SenderName" Text=""/>

                                    <TextBlock VerticalAlignment="Bottom" Text="Your Email" TextWrapping="Wrap" FontSize="10"/>
                                    <TextBox x:Name="PART_SenderEmail" Text="" />

                                    <TextBlock VerticalAlignment="Bottom" Text="Send To" TextWrapping="Wrap" FontSize="10"/>
                                    <TextBox x:Name="PART_SendTo" Text="" Height="100" />
                                </StackPanel>

                                <StackPanel Grid.Row="0" Grid.Column="1" Margin="5">
                                    <local:CaptchaControl x:Name="PART_CaptchaControl" />
                                    <Button Grid.Column="1" x:Name="PART_SendButton" Content="{TemplateBinding SendText}">
                                        <ToolTipService.ToolTip>
                                            <TextBlock Text="{TemplateBinding SendText}" />
                                        </ToolTipService.ToolTip>                                        
                                    </Button>
                                </StackPanel>

                                <StackPanel Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2">
                                    <TextBox x:Name="messageSavedButNotSent" IsReadOnly="True" Visibility="Collapsed" Background="#BBFF0000" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Text="Your greeting has been saved to server but no email(s) has been sent." TextWrapping="Wrap" FontSize="11"/>
                                    <TextBox x:Name="messageSaved" IsReadOnly="True" Visibility="Collapsed" Background="#6600FF00" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Text="{TemplateBinding SucceededMessage}" TextWrapping="Wrap" FontSize="11"/>
                                    <TextBox x:Name="messageCaptchaFailed" Visibility="Collapsed" Background="#BBFF0000" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Text="Captcha validation failed, please try again." TextWrapping="Wrap" FontSize="11"/>
                                </StackPanel>

                            </Grid>
                        </Border>

                        <waitCursor:WaitCursorControl Grid.Row="0" Grid.RowSpan="2" x:Name="disableControlsArea" Text="Connecting..." Background="#99FFFFFF" Visibility="Collapsed"/>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>